## Clean the qualtrics file


library(qualtRics)
library(tidyverse)


# Read the raw qualtrics file (includes pilot people and previews)
data <- read_survey("data/exp2/Blurring_study2v3_December 24, 2022_07.04.csv") 


# Keep people who finished the study and whom are not in the pilot
data <- data %>% filter(!is.na(data$rid) | !is.na(id)) # filters out all the previews
data <- data %>% filter(gc==1) #only keep people that finished the survey
data <- data %>% filter((batch=="post first pilot" | 
                           batch=="post first stop") & !is.na(batch)) # Only keep people after the pilot 


# Drop the fastest 5% of respondents (39 people)
head(sort(data$`Duration (in seconds)`), n=39)
data <- data %>% filter(`Duration (in seconds)`>146)  

# Select the right variables
data <- data %>% select(Education, Gender, data_outcome_binar, pos_data, data_outcome_pa_1, data_outcome_pa_2,
                        data_outcome_pa_3, data_outcome_pb_3, data_outcome_pa_4, data_outcome_pb_4,
                        data_outcome_pb_1, data_outcome_pb_2, treatment_data, 
                        data_imp_1, data_imp_9, data_imp_7, data_imp_10,
                        wage_binary, treatment_wage, wage_partya_1, wage_partya_2,
                        wage_partyb_1, wage_partyb_2, wage_imp_1, wage_imp_9, 
                        wage_updating_5)



# Save as Rda
save(data,file="data/final_exp2.Rda")


